#include "../../config.h"

#include <stdio.h>
#include <sys/types.h>
#include <stdint.h>

typedef struct {
  uint32_t range_s;
  uint32_t range_e;
  uint32_t offset;
  size_t   multiple;
} NORMAL_RE_TABLE;
typedef struct {
  uint32_t from;
  uint32_t to;
} NORMAL_RE_MAP;

/* gpyp2の変換テーブルの流用 */
NORMAL_RE_TABLE normal_re_table[] = {
  {0x30A1, 0x30F6, 0x3041, 1}, // カタカナ
  {0xFF01, 0xFF5E, 0x0021, 1}, // 全角ASCII
  {0xFF71, 0xFF75, 0x3042, 2}, // ｱ-ｵ
  {0xFF76, 0xFF7A, 0x304B, 2}, // ｶ-ｺ
  {0xFF7B, 0xFF7F, 0x3055, 2}, // ｻ-ｿ
  {0xFF80, 0xFF81, 0x305F, 2}, // ﾀ-ﾁ
  {0xFF82, 0xFF84, 0x3064, 2}, // ﾂ-ﾄ
  {0xFF85, 0xFF89, 0x306A, 1}, // ﾅ-ﾉ
  {0xFF8A, 0xFF8E, 0x306F, 3}, // ﾊ-ﾎ
  {0xFF8F, 0xFF93, 0x307E, 1}, // ﾏ-ﾓ
  {0xFF94, 0xFF96, 0x3084, 2}, // ﾔ-ﾖ
  {0xFF97, 0xFF9B, 0x3089, 1}, // ﾗ-ﾛ
  {0xFF67, 0xFF6B, 0x3041, 2}, // ｧ-ｫ
  {0xFF6C, 0xFF6E, 0x3083, 2}, // ｬｭｮ
  {'a',    'z',    'A',    1},
  {0x2460, 0x2468, '1',    1}, // ①-⑨
  {0x2474, 0x247C, '1',    1}, // ⑴-⑼
  {0x2488, 0x2490, '1',    1}, // ⒈-⒐
  {0x249C, 0x24B5, 'A',    1}, // ⒜-⒵
  {0x24B6, 0x24CF, 'A',    1}, // Ⓐ-Ⓩ
  {0x24D0, 0x24E9, 'A',    1}, // ⓐ-ⓩ
  {0x24F5, 0x24FD, '1',    1}, // ⓵-⓽
  {0x2160, 0x2168, '1',    1}, // Ⅰ-Ⅸ
  {0x2170, 0x2178, '1',    1}, // ⅰ-ⅸ
};
NORMAL_RE_MAP normal_re_map[] = {
  {0x3000, 0x0020}, // スペース
  {'\t',   0x0020}, // タブ
  {0x30FC, 0x002D}, // ー
  {0xFF6F, 0x3063}, // ｯ
  {0xFF9C, 0x308F}, // ﾜ
  {0xFF66, 0x3092}, // ｦ
  {0xFF9D, 0x3093}, // ﾝ
  {0x301C, 0x007E}, // 〜
  {0xFFE5, 0x00A5}, // ￥
  {0x3090, 0x3044}, // ゐ
  {0x30F0, 0x3044}, // ヰ
  {0x3091, 0x3048}, // ゐ
  {0x30F1, 0x3048}, // ヱ
  {0x24EA, '0'},    // ⓪
};

int main(int/* argc*/, char */*argv*/[]) {
  for(size_t i = 0; i < sizeof(normal_re_table) / sizeof(NORMAL_RE_TABLE); ++i) {
    NORMAL_RE_TABLE *table = normal_re_table + i;
    for(uint32_t c = table->range_s; c <= table->range_e; ++c) {
      printf("{0x%04X, 0x%04X},\n", c, (c - table->range_s) * table->multiple + table->offset);
    }
  }
  for(size_t i = 0; i < sizeof(normal_re_map) / sizeof(NORMAL_RE_MAP); ++i) {
    printf("{0x%04X, 0x%04X},\n", normal_re_map[i].from, normal_re_map[i].to);
  }
}
